Release 10.1A: OpenEdge Development:
Programming Interfaces
Authorizing users from within a given procedure
This sections shows some examples of procedures that you can use to check for user IDs in order to run the given procedure. The following procedure uses
_prostar.p:
This procedure defines user access by first running the
_prostar.pprocedure before displaying the following main menu in a character environment:
![]()
Suppose you want to define, on a per procedure basis, the individuals who can run each of the Maintenance and Reporting menu procedures. You can use the
CAN–DOfunction to check the user ID(s) established by_prostar.p. Thei-adcust.pprocedure allows you to enter customer information:
If you want to limit the use of this procedure to database connection that have a database connection ID of
managerorsalesrep, you can modify the procedure as follows to authorize access based on the database connection ID for single connected database:i-adcus2.p
![]()
The first part of
i-adcus2.pauthorizes the user to run the procedure. TheCAN–DOfunction compares the values listed in the parentheses against the database connection ID for a single connected database. If the database connection ID does not match any of the values listed, the procedure displays a message and exits. If the database connection ID does match one of the values (listed user IDs), the procedure continues executing.The ID list you provide in the
CAN–DOfunction is a comma-separated list of user ID tokens. You can use tokens to indicate specific users who have or do not have access. Table 2–10 lists the types of tokens you can specify.
For more information on the
CAN–DOfunction, see the OpenEdge Development: Progress 4GL Reference .You can also use the
USERIDfunction (with a specified or single database connection) to check user IDs in a procedure. Use this function when you want to allow only one user ID access to a procedure:i-adcus3.p
![]()
If the user ID of the user running the procedure is not
manager, the procedure displays a message and exits. If the user ID ismanager, the procedure continues.If you use either the
CAN–DOfunction or theUSERIDfunction to compare the specified database connection ID with one or more user IDs you hard-code in a procedure, you must modify and recompile that procedure whenever you change the user IDs allowed access to it. You can avoid having to make these changes by building a permissions table for activities in your application. For more information, see the "Defining activities-based user authorization" section.Also, given a single string of user IDs, the
Note: The second argument of theCAN-DOfunction, by default, validates the singleUSERID(database connection ID) value for a single database connection. If you connect to more than one database, aUSERIDfunction requires a specified logical database name and aCAN–DOfunction requires a second argument consisting of an explicitUSERIDfunction with a specified logical database name. For more information on multiple-database considerations, see OpenEdge Development: Progress 4GL Handbook .CAN-DOfunction can also consist of a string expression that specifies an authenticated user ID other than the database connection ID. For example, you can specify theUSER-IDattribute of a client-principal object validated against the application trusted domain registry to specify the Progress session ID. In this way, you can use theCAN-DOfunction to authorize procedure access independent of any database connection. For more information, see the "Authenticating user identities" section. You can also use the list of user roles set for theROLESattribute on the client-principal object to identify user permissions for theCAN-DOfunction, for example:IF CAN-DO(hCP:ROLES, "Admin") THEN ...
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |